<%@ page import="db.DBConnection" %>
<%@ page import="db.User" %>
<%
    int user_id = -1;
    String secret1 = "";
    Cookie[] cookies = request.getCookies();

    for (Cookie cookie : cookies) {
        if (cookie.getName().equals("user_id")) {
            user_id = Integer.parseInt(cookie.getValue());
        } else if (cookie.getName().equals("secret")) {
            secret1 = cookie.getValue();
        }
    }
    DBConnection dbConnection = new DBConnection();
    if (!dbConnection.isCookieOk(user_id, secret1)) {
        String redirectURL = "../index.jsp";
        response.sendRedirect(redirectURL);
    }
    int num = dbConnection.doGetNumberOfUnreadMessages(user_id);

    User user = null;
    if (user_id != -1) {
        user = dbConnection.getUserInfo(user_id, user_id);
    } else {
        String redirectURL = "../index.jsp";
        response.sendRedirect(redirectURL);
    }
%>

<%--
  Created by IntelliJ IDEA.
  User: user
  Date: 07.05.12
  Time: 19:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Personal info</title>
    <link rel="stylesheet" type="text/css" href="style"/>

</head>
<body>
<div class="logout" style="text-align:right;"><a href="../logout.jsp">  Logout</a></div>

<div class="header"> <img src="logo.jpg"> </div>
<div class="layout">
    <div class="sidebar">

        <ul class="cssmenu">
            <li><b><a href="personal_info.jsp">Personal info</a></b></li>
            <li><a href="operations.jsp">Operations</a></li>
            <li><a href="messages.jsp">Messages<% if (num != 0) {%> <b> (<%=num%>)</b> <%}%></a></li>
        </ul>
    </div>
    <div class="content">
        <p>Personal info</p>
        <hr  width="400" align="left"/>
        <table class="table">
            <tr>
                <td width="150">First name:</td>
                <td><%= user.firstName%></td>
            </tr>
            <tr>
                <td>Last name:</td>
                <td><%= user.lastName%></td>
            </tr>
            <tr>
                <td>Other name:</td>
                <td><%= user.otherName%></td>
            </tr>
            <tr>
                <td>Sex:</td>
                <td><%= user.sex%></td>
            </tr>
            <tr>
                <td>Date of birth:</td>
                <td><%= user.birthDate%></td>
            </tr>
            <tr>
                <td>Place of birth:</td>
                <td><%= user.birthPlace%></td>
            </tr>            
            <tr>
                <td>Country:</td>
                <td><%= user.country %></td>
            </tr>
            <tr>
                <td>City:</td>
                <td><%= user.city%></td>
            </tr>
            <tr>
                <td>Address:</td>
                <td><%= user.address%></td>
            </tr>
            <tr>
                <td>Post index:</td>
                <td><%= user.postIndex%></td>
            </tr>
        </table>
        <p>Certificate of identity</p>
        <hr width="400" align="left"/>
        <table class="table">
            <tr>
                <td width="150">Number of passport:</td>
                <td><%= user.passportNumber%></td>
            </tr>
            <tr>
                <td>Passport given by:</td>
                <td><%= user.passportPlace %></td>
            </tr>
            <tr>
                <td>Date of issue:</td>
                <td><%= user.passportDate%></td>
            </tr>
            
        </table>

    </div>
</div>
</body>
</html>